package me.vudu.Conflict.Listeners;




import me.vudu.Conflict.ConflictPlugin;
import me.vudu.Conflict.Listeners.Skills.SkillScreenListener;

import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;

/**
 * reagiert auf Player Joind und Leave
 * aktualisiert die Player-Liste entsprechend
 * @author vwendel
 *
 */
public class PlayerRespawnListener implements Listener{
	
	ConflictPlugin plugin;
	
	public PlayerRespawnListener(ConflictPlugin plugin){
		Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
		this.plugin=plugin;
	}
	

	@EventHandler(priority = EventPriority.HIGHEST)
    public void PlayerRespawn(final PlayerRespawnEvent event){	
		
		
		
		
		Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable(){

			@Override
			public void run() {
				
				SpoutPlayer sp = SpoutManager.getPlayer(event.getPlayer());
			//	Bukkit.getLogger().log(Level.INFO, sp.getName()+"RESPAWN");
				SkillScreenListener.updatePlayerValues(sp);
				
			}
			
			
		},50 );
		
		
	}
	

}
